package com.budwk.app.util.poiUtils;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.text.StrFormatter;
import com.budwk.app.sqfw.dto.AbstractExcelParamDTO;
import com.budwk.app.sqfw.dto.FireHiddenCheckWordDTO;
import com.budwk.app.sqfw.dto.FireHiddenExcelParamJinYuanSQDTO;
import com.budwk.app.sqfw.dto.JinYangStreetFireHiddenCheckWordDTO;
import com.budwk.app.sqfw.enums.DownLoadFileNameEnum;
import com.budwk.app.sqfw.enums.JinYangExcelType;
import com.budwk.app.sqfw.models.Sqfw_formSummary;
import com.budwk.app.sqfw.vo.GenerateWordAndPdfUrlVO;
import com.budwk.app.sqfw.vo.VisAndInsForJinYangJieDaoExcelVO;
import com.budwk.app.util.poiUtils.excelPictureConfigBO.ExcelFileCreateParamBO;
import com.budwk.app.util.poiUtils.excelPictureConfigBO.FireHiddenExcelJinYuanSQBO;
import com.budwk.app.util.poiUtils.excelPictureConfigBO.FireHiddenExcelSNSQ;
import com.deepoove.poi.data.TextRenderData;
import com.deepoove.poi.data.style.Style;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;

import java.io.ByteArrayOutputStream;
import java.lang.reflect.Field;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicReference;

import static com.budwk.app.util.poiUtils.CommonFormOfficeUtils.*;

/**
 * @author ZY.Wang
 * @since 2023/7/19
 */
public class FireHiddenOfficeUtils {

    /**
     * 生成花果园消防安全表单
     *
     * @param formSummary 表单数据
     * @return 创建的PDF链接
     */
    public static GenerateWordAndPdfUrlVO createFireHiddenHuaGuoYuan(FireHiddenCheckWordDTO formSummary) {

        ByteArrayOutputStream baseFireHiddenOS = null;
        ByteArrayOutputStream gasInspectionWordOS = null;
        ByteArrayOutputStream sitePictWordOS = null;
        try {
            // 基础消防安全排查
            baseFireHiddenOS = createFireHiddenCheckFormHuaGuoYuan(formSummary);

            // 如果含有煤气相关条件的需要生成煤气pdf
            gasInspectionWordOS = GasInspectionOfficeUtils.createGasInspectionCheckForm(formSummary);

            // 现场照片生成
            List<SitePictureOfficeUtils.SitePictureContent> sitePictureContentList = Lists.newArrayList();
            if (StringUtils.isNotBlank(formSummary.getA9())) {
                List<String> pictureList = Lists.newArrayList(Lists.newArrayList(formSummary.getA9().split(",")));
                String textStr = "附件：{} {} 整改后照片";
                textStr = StrFormatter.format(textStr, formSummary.getA1(), DateUtil.format(formSummary.getCreateDate(), "yyyy-MM-dd"));
                sitePictureContentList.add(new SitePictureOfficeUtils.SitePictureContent(textStr, pictureList));
            }
            sitePictWordOS = SitePictureOfficeUtils.createSitePicture(sitePictureContentList);

            ArrayList<ByteArrayOutputStream> osList = Lists.newArrayList(baseFireHiddenOS, gasInspectionWordOS, sitePictWordOS);

            //String fileName = StrFormatter.format("{}安全排查整治表{}", formSummary.getA1(), DateUtil.format(new Date(), "yyyyMMdd"));
            //zhangp 2023-12-13 文件名称格式统一
            String downloadFileName = DownLoadFileNameEnum.SAFETY_INVESTIGATE_RENOVATE.getName();
            String fileName = StrFormatter.format("{}{}{}", formSummary.getA1(), downloadFileName, DateUtil.format(new Date(), "yyyyMMdd"));

            return wordToPdfAndUpload(osList, fileName, "花果园消防安全排查");
        } catch (Exception e) {
            return new GenerateWordAndPdfUrlVO();
        } finally {
            IoUtil.close(baseFireHiddenOS);
            IoUtil.close(gasInspectionWordOS);
            IoUtil.close(sitePictWordOS);
        }
    }

    /**
     * 生成花果园消防安全排查Excel
     *
     * @param fireHiddenExcelParamDTO 消防安全DTO
     * @return excel链接
     */
    public static String createFireHiddenExcel(AbstractExcelParamDTO fireHiddenExcelParamDTO,String isCheckData) {
        Map<String, Object> excelParam = new HashMap<>();
        excelParam.put("unitName", fireHiddenExcelParamDTO.getCompleteUnitName());
        excelParam.put("fillUnitName", fireHiddenExcelParamDTO.getCompleteUnitName());
        excelParam.put("downloadDate", DateUtil.format(new Date(), "yyyy 年 M 月 dd 日"));

        List<Map<String, Object>> listMap = new ArrayList<>();
        List<Sqfw_formSummary> formSummaryList = fireHiddenExcelParamDTO.getFormSummaryList();
        for (int i = 0; i < formSummaryList.size(); i++) {
            //zhangp 2024-01-05 检测到有数据就返回
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                return "true";
            }
            Sqfw_formSummary formSummary = formSummaryList.get(i);
            Map<String, Object> lm = new HashMap<>();
            lm.put("num", i + 1 + "");
            lm.put("unitName", fireHiddenExcelParamDTO.getCompleteUnitName());
            lm.put("a3", formSummary.getA3());

            // wzy 2023-8-2 花果园需要下面这几个字段
            lm.put("a4", formSummary.getA4());
            lm.put("a5", formSummary.getA5());
            lm.put("a6", formSummary.getA6());
            lm.put("a7", formSummary.getA7());

            lm.put("a1", formSummary.getA1());
            lm.put("a16", formSummary.getA16());

            Date fillDate = formSummary.getFillDate();
            if (fillDate == null) fillDate = formSummary.getCreateDate();
            lm.put("fillDateStr", DateUtil.format(fillDate, "yyyy.MM.dd"));
            lm.put("a18", formSummary.getA18());

            lm.put("a17", formSummary.getA17());

            String a41 = formSummary.getA41();
            if (StringUtils.isBlank(a41)) a41 = "无";
            lm.put("a41", a41);

            lm.put("a2", formSummary.getA2());
            lm.put("a8", formSummary.getA8());
            lm.put("recMea", formSummary.getA66());

            String hiddenCountStr = formSummary.getA43();   // 总的隐患条数
            if (StringUtils.isBlank(hiddenCountStr) || Integer.parseInt(hiddenCountStr) == 0) {
                lm.put("recDeadLine", "无");
                lm.put("a43", "");
                lm.put("a44", "");
                lm.put("a45", "");
                lm.put("rec", "");
            } else {
                int hiddenCount, siteRecCount, deadLineRecCount;

                String siteRecCountStr = formSummary.getA44();
                String deadLineRecStr = formSummary.getA45();
                hiddenCount = StringUtils.isBlank(hiddenCountStr) ? 0 : Integer.parseInt(hiddenCountStr);
                siteRecCount = StringUtils.isBlank(siteRecCountStr) ? 0 : Integer.parseInt(siteRecCountStr);
                deadLineRecCount = StringUtils.isBlank(deadLineRecStr) ? 0 : Integer.parseInt(deadLineRecStr);
                lm.put("a43", hiddenCount + "");
                lm.put("a44", siteRecCount + "");
                lm.put("a45", deadLineRecCount + "");
                lm.put("recDeadLine", "无");


                String recDeadLineDateStr = formSummary.getA42();
                if (StringUtils.isNotBlank(recDeadLineDateStr)) {
                    Date recDeadLineDate = DateUtil.parse(recDeadLineDateStr, "yyyy-MM-dd");
                    recDeadLineDate = DateUtil.endOfDay(recDeadLineDate);

                    String recDeadLine = "";
                    if (hiddenCount == 0) recDeadLine = "无";
                    if (hiddenCount > 0) {
                        long recDay = DateUtil.betweenDay(formSummary.getCreateDate(), recDeadLineDate, false);
                        if (recDay == 0) recDeadLine = "现场";
                        if (recDay > 0) recDeadLine = recDay + "天";
                    }
                    lm.put("recDeadLine", recDeadLine);
                }

                String rec = "待整改";
                if (hiddenCount - siteRecCount == 0) rec = "已完成";
                lm.put("rec", rec);
            }
            lm.put("a20", formSummary.getA20());
            listMap.add(lm);
        }
        if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
            if (listMap.isEmpty()) {
                return "false";
            }
        }
        excelParam.put("list", listMap);

        String fileName = DownLoadFileNameEnum.HIDDEN_DANGER_INVESTIGATE_RENOVATE.getName();

        // 这里有两个模板的原因是 除了地址一项格式不一样其他的都一样
        String excelTemplateName = "fireSafetyinvRec.xlsx";
        if (fireHiddenExcelParamDTO.getCompleteUnitName().contains("花果园"))
            excelTemplateName = "fireSafetyinvRecHGY.xlsx";
        String path = getTemplatePathByOS(excelTemplateName);

        ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
        excelFileCreateParam.setTemplatePath(path);
        excelFileCreateParam.setSheetParam(excelParam);
        excelFileCreateParam.setDataList(listMap);
        excelFileCreateParam.setClazz(null);
        //excelFileCreateParam.setFileName("Excel隐患排查整治清单");
        excelFileCreateParam.setFileName(fileName);

        excelFileCreateParam.setReturnWebUrlFlag(fireHiddenExcelParamDTO.getReturnWebUrlFlag());

        return createExcelAndUpload(excelFileCreateParam);
    }

    //------------------------------------------------------------------------------------------------------------------
    //  下面是油榨街的实现
    //------------------------------------------------------------------------------------------------------------------

    /**
     * 生成市南社区的消防安全排查表
     *
     * @param wordDTO 表单数据
     * @return 结果
     */
    public static GenerateWordAndPdfUrlVO createFireHiddenYouZhaJieShiNanSQ(FireHiddenCheckWordDTO wordDTO) {
        // 生成油榨街 消防安全排查pdf
        ByteArrayOutputStream baseFireHiddenOS = FireHiddenOfficeUtils.createFireHiddenCheckFormSNSQ(wordDTO);

        // 根据条件增加安全隐患通知书
        ByteArrayOutputStream recNoticeWordOS = RecNoticeOfficeUtils.createRecNoticeOfficeUtils(wordDTO);

        // 添加现场照片
        List<SitePictureOfficeUtils.SitePictureContent> sitePictureContentList = Lists.newArrayList();
        if (StringUtils.isNotBlank(wordDTO.getA9())) {
            List<String> pictureList = Lists.newArrayList(Lists.newArrayList(wordDTO.getA9().split(",")));
            String textStr = "附件：{} {} 现场照片";
            textStr = StrFormatter.format(textStr, wordDTO.getA1(), DateUtil.format(wordDTO.getCreateDate(), "yyyy-MM-dd"));
            sitePictureContentList.add(new SitePictureOfficeUtils.SitePictureContent(textStr, pictureList));
        }
        if (StringUtils.isNotBlank(wordDTO.getA11())) {
            List<String> pictureList = Lists.newArrayList(Lists.newArrayList(wordDTO.getA11().split(",")));
            String textStr = "附件：{} {} 整改前照片";
            textStr = StrFormatter.format(textStr, wordDTO.getA1(), DateUtil.format(wordDTO.getCreateDate(), "yyyy-MM-dd"));
            sitePictureContentList.add(new SitePictureOfficeUtils.SitePictureContent(textStr, pictureList));
        }
        if (StringUtils.isNotBlank(wordDTO.getA12())) {
            List<String> pictureList = Lists.newArrayList(Lists.newArrayList(wordDTO.getA12().split(",")));
            String textStr = "附件：{} {} 整改后照片";
            textStr = StrFormatter.format(textStr, wordDTO.getA1(), DateUtil.format(wordDTO.getCreateDate(), "yyyy-MM-dd"));
            sitePictureContentList.add(new SitePictureOfficeUtils.SitePictureContent(textStr, pictureList));
        }
        ByteArrayOutputStream sitePictWord = SitePictureOfficeUtils.createSitePicture(sitePictureContentList);

        List<ByteArrayOutputStream> osList = Lists.newArrayList(baseFireHiddenOS, recNoticeWordOS, sitePictWord);

        // 将四个word合并成一个pdf上传
        //String fileName = StrFormatter.format("{}安全排查整治表{}", wordDTO.getA1(), DateUtil.format(new Date(), "yyyyMMdd"));
        //zhangp 2023-12-13 文件名称格式统一
        String downloadFileName = DownLoadFileNameEnum.SAFETY_INVESTIGATE_RENOVATE.getName();
        String fileName = StrFormatter.format("{}{}{}", wordDTO.getA1(), downloadFileName, DateUtil.format(new Date(), "yyyyMMdd"));

        return wordToPdfAndUpload(osList, fileName, "花果园安全隐患排查表");
    }

    private static ByteArrayOutputStream createFireHiddenCheckFormSNSQ(FireHiddenCheckWordDTO formSummary) {
        long startTime = System.currentTimeMillis();

        Map<String, Object> paramMap = Maps.newHashMap();

        paramMap.put("a1", formSummary.getA1());
        paramMap.put("a2", formSummary.getA2());
        paramMap.put("a3", formSummary.getA3());

        paramMap.put("a21", formSummary.getA21());
        paramMap.put("a22", formSummary.getA22());
        paramMap.put("a23", formSummary.getA23());
        paramMap.put("a24", formSummary.getA24());
        paramMap.put("a25", formSummary.getA25());
        paramMap.put("a26", formSummary.getA26());
        paramMap.put("a27", formSummary.getA27());
        paramMap.put("a28", formSummary.getA28());
        paramMap.put("a29", formSummary.getA29());
        paramMap.put("a30", formSummary.getA30());
        paramMap.put("a31", formSummary.getA31());
        paramMap.put("a32", formSummary.getA32());

        paramMap.put("a40", formSummary.getA40());

        Date fillDate = formSummary.getFillDate();
        if (fillDate == null) fillDate = formSummary.getCreateDate();
        paramMap.put("fillDateStr", DateUtil.format(fillDate, "yyyy-MM-dd"));

        paramMap.put("a42", formSummary.getA42());

        String a18 = formSummary.getA18();
        if (StringUtils.isNotBlank(a18)) {
            // 模板的格式应该为 {{a18NoSig}}{{?a18Pics}}{{@a18Pic}}{{/a18Pics}}
            addWordUserSignature(paramMap, "a18NoSig", "a18Pics", "a18Pic", formSummary.getA18NoSignatureUsers(), formSummary.getA18UserSignatureUrls(), 1.2F);
        }

        String a19 = formSummary.getA19();
        paramMap.put("a19", addWordPicture(a19, 1.2F));

        paramMap.put("a8", formSummary.getA8());

        return generateWordDocument(paramMap, "fireSafetySNSQ.docx", "市南社区消防调查表", startTime);
    }

    private static ByteArrayOutputStream createFireHiddenCheckFormHuaGuoYuan(FireHiddenCheckWordDTO formSummary) {

        long startTime = System.currentTimeMillis();

        Map<String, Object> paramMap = Maps.newHashMap();

        String unitName = formSummary.getCompleteUnitName();

        paramMap.put("unitName", unitName);

        Date fillDate = formSummary.getFillDate();
        if (fillDate == null) fillDate = formSummary.getCreateDate();
        paramMap.put("fillDateStr", DateUtil.format(fillDate, "yyyy-MM-dd"));
        paramMap.put("a1", formSummary.getA1());
        paramMap.put("a2", formSummary.getA2());

        String areaStr = formSummary.getA3();
        String buildingStr = formSummary.getA4();
        String areaUnitStr = formSummary.getA5();
        String storeyStr = formSummary.getA6();
        String houseNumber = formSummary.getA7();
        String unitAddress = "";
        if (StringUtils.isNotBlank(areaStr)) unitAddress += (areaStr + "区");
        if (StringUtils.isNotBlank(buildingStr)) unitAddress += (buildingStr + "栋");
        if (StringUtils.isNotBlank(areaUnitStr)) unitAddress += (areaUnitStr + "单元");
        if (StringUtils.isNotBlank(storeyStr)) unitAddress += (storeyStr + "层");
        if (StringUtils.isNotBlank(houseNumber)) unitAddress += (houseNumber + "号");
        paramMap.put("unitAddress", unitAddress);

        paramMap.put("a3", formSummary.getA3());
        paramMap.put("a4", formSummary.getA4());
        paramMap.put("a5", formSummary.getA5());
        paramMap.put("a6", formSummary.getA6());
        paramMap.put("a7", formSummary.getA7());
        paramMap.put("a8", formSummary.getA8());

        String a11 = formSummary.getA11();
        if (StringUtils.isBlank(a11)) a11 = "       ";
        paramMap.put("a11", a11);

        String a12 = formSummary.getA12();
        if (StringUtils.isBlank(a12)) a12 = "  ";
        paramMap.put("a12", a12);

        String a13 = formSummary.getA13();
        if (StringUtils.isBlank(a13)) a13 = "       ";
        paramMap.put("a13", a13);

        String a14 = formSummary.getA14();
        if (StringUtils.isBlank(a14)) a14 = "   ";
        paramMap.put("a14", a14);

        String a15 = formSummary.getA15();
        String a15Str = a15;
        if (StringUtils.isNotBlank(a15)) a15Str = "：" + a15 + "人";
        paramMap.put("a15Str", a15Str);

        paramMap.put("a17", formSummary.getA17());

        String a18 = formSummary.getA18();
        if (StringUtils.isNotBlank(a18)) {
            // 模板的格式应该为 {{a18NoSig}}{{?a18Pics}}{{@a18Pic}}{{/a18Pics}}
            addWordUserSignature(paramMap, "a18NoSig", "a18Pics", "a18Pic", formSummary.getA18NoSignatureUsers(), formSummary.getA18UserSignatureUrls(), 1.2F);
        }

        String a19 = formSummary.getA19();
        paramMap.put("a19", addWordPicture(a19, 1.0F));

        paramMap.put("a40", formSummary.getA40());

        String A42 = formSummary.getA42();
        if (StringUtils.isNotBlank(A42)) {
            DateTime dateTime = DateUtil.parse(A42, "yyyy-MM-dd");
            paramMap.put("a42Year", dateTime.year());
            paramMap.put("a42Month", dateTime.month() + 1);
            paramMap.put("a42Day", dateTime.dayOfMonth());
        } else {
            paramMap.put("a42Year", "");
            paramMap.put("a42Month", "");
            paramMap.put("a42Day", "");
        }

        // 一些勾选的选项要进行赋值
        List<Map<String, TextRenderData>> fireHiddenTextMapList = Lists.newArrayList();
        Field[] fields = Sqfw_formSummary.class.getDeclaredFields();

        int indexForWord = 0;
        for (Field field : fields) {
            field.setAccessible(true);
            String fieldName = field.getName();
            if (!fieldName.startsWith("a")) continue;
            int fieldIndex = 0;
            try {
                fieldIndex = Integer.parseInt(fieldName.replace("a", ""));
            } catch (Exception ignored) {
            }

            if (fieldIndex == 0) continue;

            if (fieldIndex >= 21 && fieldIndex <= 39) {
                indexForWord++;
                try {
                    Object fieldValueObj = field.get(formSummary);

                    String fieldValue = "否";
                    if (fieldValueObj != null) fieldValue = (String) fieldValueObj;

                    paramMap.put(fieldName, fieldValue);

                    // 处理下划线
                    String indexStr = indexForWord + "";
                    TextRenderData textRenderData = new TextRenderData(indexStr);

                    Style style = new Style();
                    if (fieldValue.equals("否")) {
                        style.setStrike(true);
                    }
                    textRenderData.setStyle(style);

                    Map<String, TextRenderData> map = Maps.newHashMap();
                    map.put("checkItem", textRenderData);
                    fireHiddenTextMapList.add(map);

                    if (indexForWord < 19) {
                        Map<String, TextRenderData> symbolMap = Maps.newHashMap();
                        symbolMap.put("checkItem", new TextRenderData("、"));
                        fireHiddenTextMapList.add(symbolMap);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

        paramMap.put("checkItems", fireHiddenTextMapList);
        return generateWordDocument(paramMap, "fireSafety.docx", "消防调查表", startTime);
    }

    /**
     * 生成市南社区消防安全排查Excel
     *
     * @param fireHiddenExcelParamDTO 消防安全排查DTO
     * @return excel链接
     */
    public static String createFireHiddenExcelYouZhaJieShiNanSQ(AbstractExcelParamDTO fireHiddenExcelParamDTO, String isCheckData) {
        Map<String, Object> paramMap = Maps.newHashMap();
        paramMap.put("unitName", fireHiddenExcelParamDTO.getCompleteUnitName());
        paramMap.put("downloadDate", DateUtil.format(new Date(), "yyyy 年 M 月 dd 日"));

        List<Map<String, Object>> listMap = new ArrayList<>();
        List<Sqfw_formSummary> formSummaryList = fireHiddenExcelParamDTO.getFormSummaryList();
        for (int i = 0; i < formSummaryList.size(); i++) {
            //zhangp 2023-12-08 检查数据时只要有数据就返回
            if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                return "true";
            }

            Sqfw_formSummary formSummary = formSummaryList.get(i);
            Map<String, Object> lm = Maps.newHashMap();
            lm.put("num", i + 1 + "");

            Date fillDate = formSummary.getFillDate();
            if (fillDate == null) fillDate = formSummary.getCreateDate();
            lm.put("fillDateStr", DateUtil.format(fillDate, "yyyy.MM.dd HH:mm"));
            lm.put("a1", formSummary.getA1());
            lm.put("a3", formSummary.getA3());
            lm.put("a2", formSummary.getA2());

            // 现场照片
            String a9 = formSummary.getA9();
            List<byte[]> a41ByteList = addPictureToByteList(a9, 1);
            lm.put("a9", a41ByteList);

            String a41 = formSummary.getA41();
            if (StringUtils.isBlank(a41)) a41 = "否";
            else a41 = "是";
            lm.put("a41", a41);

            String a11 = formSummary.getA11();
            List<byte[]> a11ByteList = addPictureToByteList(a11, 1);
            lm.put("a11", a11ByteList);

            String a12 = formSummary.getA12();
            List<byte[]> a12ByteList = addPictureToByteList(a12, 1);
            lm.put("a12", a12ByteList);

            lm.put("a20", formSummary.getA20());

            listMap.add(lm);
        }
        if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
            if (listMap.isEmpty()) {
                return "false";
            }
        }

        String templatePath = getTemplatePathByOS("fireSafetyinvRecSNSQ.xlsx");
        //String fileName = "Excel隐患排查整治清单";
        String fileName = DownLoadFileNameEnum.HIDDEN_DANGER_INVESTIGATE_RENOVATE.getName();

        if (StringUtils.isNotBlank(fireHiddenExcelParamDTO.getFileNameSuffix()))
            fileName = fileName + fireHiddenExcelParamDTO.getFileNameSuffix();

        ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
        excelFileCreateParam.setTemplatePath(templatePath);
        excelFileCreateParam.setSheetParam(paramMap);
        excelFileCreateParam.setDataList(listMap);
        excelFileCreateParam.setClazz(FireHiddenExcelSNSQ.class);
        excelFileCreateParam.setFileName(fileName);
        excelFileCreateParam.setReturnWebUrlFlag(fireHiddenExcelParamDTO.getReturnWebUrlFlag());

        return createExcelAndUpload(excelFileCreateParam);
    }


    //------------------------------------------------------------------------------------------------------------------
    //  下面是金元社区的一些实现
    //------------------------------------------------------------------------------------------------------------------

    /**
     * 金元社区安全排查word和pdf生成
     *
     * @param formSummary 表单数据
     * @return word和pdf结果
     */
    public static GenerateWordAndPdfUrlVO createFireHiddenJinYuanSQ(JinYangStreetFireHiddenCheckWordDTO formSummary) {

        // 一共可能要生成4个pdf
        List<ByteArrayOutputStream> osList = Lists.newArrayList();

        // 预先准备创建人签名数据，因为这个四个pdf都可以使用
        List<String> cuNoSigList = Lists.newArrayList();
        List<String> cuSigList = Lists.newArrayList();
        String jinYuanGasInsCreatUserSig = formSummary.getJinYuanFireHiddenCreateUserSig();
        if (StringUtils.isNotBlank(jinYuanGasInsCreatUserSig)) cuSigList.add(jinYuanGasInsCreatUserSig);
        else cuNoSigList.add(formSummary.getCreateUserName());

        // 首先生成走访巡查表 visAndInsJinYuanSQ.docx
        Map<String, Object> visAndInsParam = Maps.newHashMap();
        visAndInsParam.put("titlePrefix", formSummary.getVisAndInsDocTitlePrefix());

        Date fillDate = formSummary.getFillDate();
        if (fillDate == null) fillDate = formSummary.getCreateDate();
        String fillDateStr = DateUtil.format(fillDate, "yyyy年MM月dd日");
        visAndInsParam.put("fillDateStr", fillDateStr);

        // 填表人签名
        addWordUserSignature(visAndInsParam, "cuNoSig", "cuSigs", "cuSig", cuNoSigList, cuSigList, 1.0F);

        visAndInsParam.put("a1", formSummary.getA1());
        visAndInsParam.put("a4", formSummary.getA4());
        visAndInsParam.put("a2", formSummary.getA2());
        visAndInsParam.put("a8", formSummary.getA8());
        visAndInsParam.put("a3", formSummary.getA3());

        // 排查人员签名
        addWordUserSignature(visAndInsParam, "a18NoSig", "a18Sigs", "a18Sig",
                formSummary.getJinYuanA18NoSigUsers(), formSummary.getJinYuanA18SigUrls(), 1.0F);

        String visAndInsA13 = formSummary.getA13();
        if (StringUtils.isNotBlank(visAndInsA13) && visAndInsA13.equals("整改完成"))
            visAndInsA13 = "无";
        visAndInsParam.put("a13", visAndInsA13);
        visAndInsParam.put("a41", formSummary.getA41());
        visAndInsParam.put("a20", formSummary.getA20());
        visAndInsParam.put("a19", addWordPicture(formSummary.getA19(), 1.2F));
        ByteArrayOutputStream visAndInsJinYuanOS = generateWordDocument(visAndInsParam, "visAndInsJinYuanSQ.docx", "走访巡查表", System.currentTimeMillis());
        osList.add(visAndInsJinYuanOS);

        // 台账
        String a13 = formSummary.getA13();
        if (StringUtils.isBlank(a13) || !a13.equals("无")) {
            Map<String, Object> standingBookParam = Maps.newHashMap();

            String a13Str = formSummary.getA13();
            if (a13.equals("有")) {
                String a42 = formSummary.getA42();
                DateTime a42Date = DateUtil.parse(a42, "yyyy-MM-dd");
                long betweenDay = DateUtil.betweenDay(new Date(), a42Date, false);
                if (betweenDay < 1) {
                    a13Str = "是";
                } else {
                    a13Str = "否";
                }
            }
            if (a13.equals("整改完成")) {
                a13Str = "是";
            }

            standingBookParam.put("titlePrefix", formSummary.getStandingBookDocTitlePrefix());
            standingBookParam.put("unitName", formSummary.getCompleteUnitName());

            // 填报人签名
            addWordUserSignature(standingBookParam, "cuNoSig", "cuSigs", "cuSig", cuNoSigList, cuSigList, 1.0F);

            standingBookParam.put("fillDateStr", fillDateStr);
            standingBookParam.put("a4", formSummary.getA4());
            standingBookParam.put("a3", formSummary.getA3());
            standingBookParam.put("a16", formSummary.getA16());
            standingBookParam.put("a15", formSummary.getA15());
            standingBookParam.put("a17", formSummary.getA17());
            standingBookParam.put("a41", formSummary.getA41());
            standingBookParam.put("a42", formSummary.getA42());
            standingBookParam.put("a2", formSummary.getA2());

            addWordUserSignature(standingBookParam, "a18NoSig", "a18Sigs", "a18Sig",
                    formSummary.getJinYuanA18NoSigUsers(), formSummary.getJinYuanA18SigUrls(), 1.2F);

            standingBookParam.put("a12", formSummary.getA12());
            standingBookParam.put("a13", a13Str);
            standingBookParam.put("a39", formSummary.getA39());
            ByteArrayOutputStream standingBookOS = generateWordDocument(standingBookParam, "standingBookJinYuanSQ.docx", "金元社区台账word", System.currentTimeMillis());
            osList.add(standingBookOS);
        }

        // 生成安全检查表
        String a21 = formSummary.getA21();
        if (StringUtils.isBlank(a21) || !a21.equals("③")) {
            Map<String, Object> gasInsParam = Maps.newHashMap();
            gasInsParam.put("titlePrefix", formSummary.getGasInsDocTitlePrefix());
            gasInsParam.put("unitName", formSummary.getCompleteUnitName());
            gasInsParam.put("fillDateStr", fillDateStr);

            // 填报人签名
            addWordUserSignature(gasInsParam, "cuNoSig", "cuSigs", "cuSig", cuNoSigList, cuSigList, 1.0F);

            gasInsParam.put("createUserPhone", formSummary.getCreateUserPhone());
            gasInsParam.put("a1", formSummary.getA1());
            gasInsParam.put("a21", formSummary.getA21());
            gasInsParam.put("a22", formSummary.getA22());
            gasInsParam.put("a23", formSummary.getA23());
            gasInsParam.put("a24", formSummary.getA24());
            gasInsParam.put("a25", formSummary.getA25());
            gasInsParam.put("a26", formSummary.getA26());
            gasInsParam.put("a43", formSummary.getA43());
            gasInsParam.put("a40", formSummary.getA40());
            gasInsParam.put("a44", formSummary.getA44());
            gasInsParam.put("a19", addWordPicture(formSummary.getA19(), 1.2F));
            ByteArrayOutputStream gasInsJinYuanOS = generateWordDocument(gasInsParam, "gasInsJinYuanSQ.docx", "金元社区安全检查", System.currentTimeMillis());
            osList.add(gasInsJinYuanOS);
        }

        // 安全隐患整改
        String a45 = formSummary.getA45();
        if (StringUtils.isNotBlank(a45) && !a45.equals("无")) {
            Map<String, Object> gasRecParam = Maps.newHashMap();
            gasRecParam.put("titlePrefix", formSummary.getGasRecDocTitlePrefix());
            gasRecParam.put("unitName", formSummary.getCompleteUnitName());
            gasRecParam.put("a1", formSummary.getA1());
            gasRecParam.put("a3", formSummary.getA3());
            gasRecParam.put("a44", formSummary.getA44());
            gasRecParam.put("a45", formSummary.getA45());
            gasRecParam.put("a10s", addWordPicture(formSummary.getA10(), "a10", 8F));
            gasRecParam.put("a11s", addWordPicture(formSummary.getA11(), "a11", 8F));
            gasRecParam.put("a46", formSummary.getA46());
            ByteArrayOutputStream gasRecJinYuanOS = generateWordDocument(gasRecParam, "gasRecJinYuanSQ.docx", "金元社区安全隐患整改表", System.currentTimeMillis());
            osList.add(gasRecJinYuanOS);
        }

        // 如果含有整改前 整改后  现场照片的
        // 添加现场照片
        List<SitePictureOfficeUtils.SitePictureContent> sitePictureContentList = Lists.newArrayList();
        if (StringUtils.isNotBlank(formSummary.getA9())) {
            List<String> pictureList = Lists.newArrayList(Lists.newArrayList(formSummary.getA9().split(",")));
            String textStr = "附件：{} {} 现场照片";
            textStr = StrFormatter.format(textStr, formSummary.getA1(), DateUtil.format(formSummary.getCreateDate(), "yyyy-MM-dd"));
            sitePictureContentList.add(new SitePictureOfficeUtils.SitePictureContent(textStr, pictureList));
        }
        if (StringUtils.isNotBlank(formSummary.getA10())) {
            List<String> pictureList = Lists.newArrayList(Lists.newArrayList(formSummary.getA10().split(",")));
            String textStr = "附件：{} {} 整改前照片";
            textStr = StrFormatter.format(textStr, formSummary.getA1(), DateUtil.format(formSummary.getCreateDate(), "yyyy-MM-dd"));
            sitePictureContentList.add(new SitePictureOfficeUtils.SitePictureContent(textStr, pictureList));
        }
        if (StringUtils.isNotBlank(formSummary.getA11())) {
            List<String> pictureList = Lists.newArrayList(Lists.newArrayList(formSummary.getA11().split(",")));
            String textStr = "附件：{} {} 整改后照片";
            textStr = StrFormatter.format(textStr, formSummary.getA1(), DateUtil.format(formSummary.getCreateDate(), "yyyy-MM-dd"));
            sitePictureContentList.add(new SitePictureOfficeUtils.SitePictureContent(textStr, pictureList));
        }
        ByteArrayOutputStream sitePictWordOS = SitePictureOfficeUtils.createSitePicture(sitePictureContentList);
        osList.add(sitePictWordOS);

        // 将四个word合并成一个pdf上传
        //String fileName = StrFormatter.format("{}安全排查整治表{}", formSummary.getA1(), DateUtil.format(new Date(), "yyyyMMdd"));
        //zhangp 2023-12-13 文件名称格式统一
        String downloadFileName = DownLoadFileNameEnum.SAFETY_INVESTIGATE_RENOVATE.getName();
        String fileName = StrFormatter.format("{}{}{}", formSummary.getA1(), downloadFileName, DateUtil.format(new Date(), "yyyyMMdd"));

        return wordToPdfAndUpload(osList, fileName, formSummary.getUnitName() + "消防安全走访巡查表");
    }

    /**
     * 生成金元社区消防安全excel
     *
     * @param excelParamDTO excel参数
     * @return excel链接
     */
    public static VisAndInsForJinYangJieDaoExcelVO createFireHiddenExcelJinYuanSQ(FireHiddenExcelParamJinYuanSQDTO excelParamDTO, String isCheckData) {

        // 油榨街的一共会生成四个excel
        ExecutorService executorService = Executors.newFixedThreadPool(50);

        AtomicReference<Boolean> errorFlag = new AtomicReference<>(false);

        String unitName = excelParamDTO.getCompleteUnitName();
        String userName = excelParamDTO.getCreateUserName();
        String userPhone = excelParamDTO.getCreateUserPhone();
        int fileIndex = excelParamDTO.getFileIndex();
        List<Sqfw_formSummary> formSummaryList = excelParamDTO.getFormSummaryList();


        // 生成巡查表
        CompletableFuture<String> visAndInsFuture = CompletableFuture.supplyAsync(() -> {

            if (fileIndex != 0 && fileIndex != 1) return "";

            try {
                Map<String, Object> sheetParam = Maps.newHashMap();
                sheetParam.put("titlePrefix", excelParamDTO.getVisAndInsExcelTitlePrefix());
                sheetParam.put("unitName", unitName);
                sheetParam.put("createDateWithYear", DateUtil.format(new Date(), "yyyy年MM月"));
                sheetParam.put("fillUserName", userName);
                sheetParam.put("downloadDate", DateUtil.format(new Date(), "yyyy年MM月dd日"));
                sheetParam.put("fillDateStr", DateUtil.format(new Date(), "yyyy年MM月dd日"));

                List<Map<String, Object>> dataList = Lists.newArrayList();
                int visAndInsNumIndex = 0;
                for (Sqfw_formSummary formSummary : formSummaryList) {
                    visAndInsNumIndex++;
                    Map<String, Object> rollData = Maps.newHashMap();
                    rollData.put("num", visAndInsNumIndex);
                    rollData.put("a1", formSummary.getA1());
                    rollData.put("a4", formSummary.getA4());
                    rollData.put("a2", formSummary.getA2());
                    rollData.put("a8", formSummary.getA8());
                    rollData.put("a3", formSummary.getA3());

                    Date fillDate = formSummary.getFillDate();
                    if (fillDate == null) fillDate = formSummary.getCreateDate();
                    rollData.put("fillDateStr", DateUtil.format(fillDate, "yyyy年MM月dd日"));

                    rollData.put("a18", formSummary.getA18());

                    String a13 = formSummary.getA13();
                    if (StringUtils.isNotBlank(a13) && a13.equals("整改完成")) a13 = "无";
                    rollData.put("a13", a13);
                    rollData.put("a41", formSummary.getA41());
                    rollData.put("a20", formSummary.getA20());

                    String a19 = formSummary.getA19();
                    List<byte[]> bytes = CommonFormOfficeUtils.addPictureToByteList(a19, 1);
                    rollData.put("a19", bytes);

                    dataList.add(rollData);
                    //zhangp 2023-12-08 检查数据时只要有数据就返回
                    if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                        return "true";
                    }
                }
                //zhangp 2023-12-04 检测数据时使用
                if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                    if (dataList.isEmpty()) {
                        return "false";
                    }
                }
                String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("visAndInsJinYuanSQ.xlsx");

                //String fileName = "Excel走访巡查集合";
                String fileName = DownLoadFileNameEnum.JY_VISITS_INSPECTION.getName();

                if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                    fileName += excelParamDTO.getFileNameSuffix();

                ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
                excelFileCreateParam.setTemplatePath(templatePath);
                excelFileCreateParam.setSheetParam(sheetParam);
                excelFileCreateParam.setDataList(dataList);
                excelFileCreateParam.setClazz(FireHiddenExcelJinYuanSQBO.class);
                excelFileCreateParam.setFileName(fileName);
                excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());

                return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
            } catch (Exception e) {
                errorFlag.set(true);
                System.out.println(StrFormatter.format("生成巡查表错误"));
            }

            return "";

        }, executorService);


        // 生成燃气检查表
        CompletableFuture<String> gasInsFuture = CompletableFuture.supplyAsync(() -> {
            if (fileIndex != 0 && fileIndex != 2) return "";
            try {
                Map<String, Object> gasInsSheetParam = Maps.newHashMap();
                gasInsSheetParam.put("titlePrefix", excelParamDTO.getGasInsExcelTitlePrefix());
                gasInsSheetParam.put("title", StrFormatter.format("{}", unitName.replace("居委会", "")));
                gasInsSheetParam.put("unitName", unitName);
                gasInsSheetParam.put("fillUserNameAndPhone", userName + " " + userPhone);
                gasInsSheetParam.put("downloadDate", DateUtil.format(new Date(), "yyyy年MM月dd日"));

                List<Map<String, Object>> gasInsSheetDataList = Lists.newArrayList();

                int gasInsNumIndex = 0;
                for (Sqfw_formSummary formSummary : formSummaryList) {
                    // 只有当a21字段等于③的时候，不生成此表
                    String a21 = formSummary.getA21();
                    if (StringUtils.isNotBlank(a21) && a21.equals("③")) continue;

                    gasInsNumIndex++;
                    Map<String, Object> rollData = Maps.newHashMap();
                    rollData.put("num", gasInsNumIndex);
                    rollData.put("a1", formSummary.getA1());
                    rollData.put("unitName", formSummary.getUnitName());
                    rollData.put("a21", formSummary.getA21());
                    rollData.put("a22", formSummary.getA22());
                    rollData.put("a23", formSummary.getA23());
                    rollData.put("a24", formSummary.getA24());
                    rollData.put("a25", formSummary.getA25());
                    rollData.put("a26", formSummary.getA26());

                    rollData.put("a43", formSummary.getA43());
                    rollData.put("a40", formSummary.getA40());
                    rollData.put("a44", formSummary.getA44());

                    String a19 = formSummary.getA19();
                    List<byte[]> bytes = CommonFormOfficeUtils.addPictureToByteList(a19, 1);
                    rollData.put("a19", bytes);

                    gasInsSheetDataList.add(rollData);
                    //zhangp 2023-12-08 检查数据时只要有数据就返回
                    if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                        return "true";
                    }
                }
                //zhangp 2023-12-04 检测数据时使用
                if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                    if (gasInsSheetDataList.isEmpty()) {
                        return "false";
                    }
                }
                String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("gasInsJinYuanSQ.xlsx");

                //String fileName = "Excel燃气检查集合";
                String fileName = DownLoadFileNameEnum.JY_GAS_INSPECTION.getName();

                if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                    fileName += excelParamDTO.getFileNameSuffix();

                ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
                excelFileCreateParam.setTemplatePath(templatePath);
                excelFileCreateParam.setSheetParam(gasInsSheetParam);
                excelFileCreateParam.setDataList(gasInsSheetDataList);
                excelFileCreateParam.setClazz(FireHiddenExcelJinYuanSQBO.class);
                excelFileCreateParam.setFileName(fileName);
                excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());

                return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
            } catch (Exception e) {
                errorFlag.set(true);
                System.out.println(StrFormatter.format("生成燃气检查表错误"));
            }

            return null;

        }, executorService);


        // 生成燃气整改情况
        CompletableFuture<String> gasRecFuture = CompletableFuture.supplyAsync(() -> {
            if (fileIndex != 0 && fileIndex != 3) return "";
            try {
                Map<String, Object> gasRecSheetParam = Maps.newHashMap();
                gasRecSheetParam.put("titlePrefix", excelParamDTO.getGasRecExcelTitlePrefix());
                gasRecSheetParam.put("title", "观山湖区" + unitName.replace("居委会", ""));
                gasRecSheetParam.put("unitName", unitName);
                gasRecSheetParam.put("fillUserNameAndPhone", userName);

                List<Map<String, Object>> gasRecSheetDataList = Lists.newArrayList();

                int gasRecNumIndex = 0;
                for (Sqfw_formSummary formSummary : formSummaryList) {
                    String a45 = formSummary.getA45();
                    if (a45.equals("正常")) continue;
                    if (a45.equals("无")) continue;

                    gasRecNumIndex++;
                    Map<String, Object> rollData = Maps.newHashMap();
                    rollData.put("num", gasRecNumIndex);
                    rollData.put("unitName", formSummary.getUnitName());
                    rollData.put("a1", formSummary.getA1());
                    rollData.put("a3", formSummary.getA3());
                    rollData.put("a44", formSummary.getA44());
                    rollData.put("a45", formSummary.getA45());

                    String a10 = formSummary.getA10();
                    List<byte[]> a10Bytes = CommonFormOfficeUtils.addPictureToByteList(a10, 2);
                    rollData.put("a10", a10Bytes);

                    String a11 = formSummary.getA11();
                    List<byte[]> a11Bytes = CommonFormOfficeUtils.addPictureToByteList(a11, 2);
                    rollData.put("a11", a11Bytes);

                    rollData.put("a46", formSummary.getA46());

                    gasRecSheetDataList.add(rollData);
                    //zhangp 2023-12-08 检查数据时只要有数据就返回
                    if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                        return "true";
                    }
                }
                //zhangp 2023-12-04 检测数据时使用
                if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                    if (gasRecSheetDataList.isEmpty()) {
                        return "false";
                    }
                }
                String templatePath = CommonFormOfficeUtils.getTemplatePathByOS("gasRecJinYuanSQ.xlsx");

                //String fileName = "Excel燃气整改情况";
                String fileName = DownLoadFileNameEnum.JY_GAS_RECTIFICATION.getName();

                if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                    fileName += excelParamDTO.getFileNameSuffix();

                ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
                excelFileCreateParam.setTemplatePath(templatePath);
                excelFileCreateParam.setSheetParam(gasRecSheetParam);
                excelFileCreateParam.setDataList(gasRecSheetDataList);
                excelFileCreateParam.setClazz(FireHiddenExcelJinYuanSQBO.class);
                excelFileCreateParam.setFileName(fileName);
                excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());

                return CommonFormOfficeUtils.createExcelAndUpload(excelFileCreateParam);
            } catch (Exception e) {
                errorFlag.set(true);
                System.out.println(StrFormatter.format("生成燃气整改情况错误"));
            }

            return "";
        }, executorService);

        // 生成台账
        CompletableFuture<String> standingBookFuture = CompletableFuture.supplyAsync(() -> {
            if (fileIndex != 0 && fileIndex != 4) return "";
            try {
                Map<String, Object> paramMap = Maps.newHashMap();
                paramMap.put("titlePrefix", excelParamDTO.getFireSafetyExcelTitlePrefix());
                paramMap.put("title", excelParamDTO.getCompleteUnitName().replace("居委会", ""));
                paramMap.put("unitName", excelParamDTO.getCompleteUnitName());
                paramMap.put("createUserNameAndPhone", excelParamDTO.getCreateUserName() + " " + userPhone);
                paramMap.put("downloadDate", DateUtil.format(new Date(), "yyyy.MM.dd"));

                Map<String, Sqfw_formSummary> latestA1AndA13Map = excelParamDTO.getLatestA1AndA13Map();

                List<Map<String, Object>> listMap = Lists.newArrayList();

                int standingNumIndex = 0;
                for (Sqfw_formSummary formSummary : formSummaryList) {
                    String a13 = formSummary.getA13();
                    if (a13.equals("无")) continue;

                    //zhangp 2023-12-08 检查数据时只要有数据就返回
                    if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                        return "true";
                    }

                    String a13Str = formSummary.getA13();
                    String a15Str = formSummary.getA15();
                    String a41Str = formSummary.getA41();
                    String a17Str = formSummary.getA17();

                    String a42Str = "";
                    if (a13.equals("有")) {
                        String a42 = formSummary.getA42();
                        DateTime a42Date = new DateTime();
                        if (StringUtils.isNotBlank(a42))
                            a42Date = DateUtil.parse(a42, "yyyy-MM-dd");
                        long betweenDay = DateUtil.betweenDay(new Date(), a42Date, true);
                        if (betweenDay < 1) {
                            a42Str = "立即";
                            a13Str = "是";
                        } else {
                            a42Str = ((int) betweenDay) + "天";
                            a13Str = "否";
                        }
                    }
                    if (a13.equals("整改完成")) {
                        Sqfw_formSummary latestA1FormSummary = latestA1AndA13Map.get(formSummary.getA1());
                        if (latestA1FormSummary != null) {
                            a15Str = latestA1FormSummary.getA15();
                            a41Str = latestA1FormSummary.getA41();
                            a17Str = latestA1FormSummary.getA17();

                            a42Str = latestA1FormSummary.getA42();
                            DateTime a42Date = new DateTime();
                            if (StringUtils.isNotBlank(a42Str))
                                a42Date = DateUtil.parse(a42Str, "yyyy-MM-dd");
                            long betweenDay = DateUtil.betweenDay(formSummary.getFillDate(), a42Date, true);
                            if (betweenDay < 1) a42Str = "立即";
                            else a42Str = (int) betweenDay + "天";

                            a13Str = "是";
                        }
                    }

                    standingNumIndex++;
                    Map<String, Object> lm = Maps.newHashMap();
                    lm.put("num", standingNumIndex);

                    Date fillDate = formSummary.getFillDate();
                    if (fillDate == null) fillDate = formSummary.getCreateDate();
                    lm.put("fillDateStr", DateUtil.format(fillDate, "yyyy.MM.dd"));
                    lm.put("a4", formSummary.getA4());
                    lm.put("a3", formSummary.getA3());
                    lm.put("a16", formSummary.getA16());

                    lm.put("a15", a15Str);
                    lm.put("a41", a41Str);
                    lm.put("a17", a17Str);
                    lm.put("a42", a42Str);
                    lm.put("unitName", formSummary.getUnitName());
                    lm.put("a2", formSummary.getA2());
                    lm.put("a18", formSummary.getA18());
                    lm.put("a12", formSummary.getA12());
                    lm.put("a13", a13Str);
                    lm.put("a39", formSummary.getA39());

                    listMap.add(lm);

                }
                //zhangp 2023-12-04 检测数据时使用
                if (StringUtils.isNotBlank(isCheckData) && isCheckData.equals("isCheckData")) {
                    if (listMap.isEmpty()) {
                        return "false";
                    }
                }
                String templatePath = getTemplatePathByOS("fireSafetyJinYuanSQ.xlsx");

                //String fileName = "Excel安全隐患台账";
                String fileName = DownLoadFileNameEnum.JY_SAFETY_HIDDEN.getName();

                if (StringUtils.isNotBlank(excelParamDTO.getFileNameSuffix()))
                    fileName += excelParamDTO.getFileNameSuffix();

                ExcelFileCreateParamBO excelFileCreateParam = new ExcelFileCreateParamBO();
                excelFileCreateParam.setTemplatePath(templatePath);
                excelFileCreateParam.setSheetParam(paramMap);
                excelFileCreateParam.setDataList(listMap);
                excelFileCreateParam.setClazz(null);
                excelFileCreateParam.setFileName(fileName);
                excelFileCreateParam.setReturnWebUrlFlag(excelParamDTO.getReturnWebUrlFlag());

                return createExcelAndUpload(excelFileCreateParam);
            } catch (Exception e) {
                e.printStackTrace();
                errorFlag.set(true);
                return null;
            }
        }, executorService);

        String visAndInsExcelUrl = "";
        String gasInsExcelUrl = "";
        String gasRecExcelUrl = "";
        String standingBookExcelUrl = "";

        try {
            visAndInsExcelUrl = visAndInsFuture.get();
            gasInsExcelUrl = gasInsFuture.get();
            gasRecExcelUrl = gasRecFuture.get();
            standingBookExcelUrl = standingBookFuture.get();
        } catch (Exception e) {
            e.printStackTrace();
            errorFlag.set(true);
        }

        executorService.shutdown();

        VisAndInsForJinYangJieDaoExcelVO resultVO = new VisAndInsForJinYangJieDaoExcelVO();
        resultVO.setVisAndInsExcelUrl(visAndInsExcelUrl);
        resultVO.setGasInsExcelUrl(gasInsExcelUrl);
        resultVO.setGasRecExcelUrl(gasRecExcelUrl);
        resultVO.setStandingBookExcelUrl(standingBookExcelUrl);
        resultVO.setErrorStatus(errorFlag.get());
        return resultVO;
    }
}
